home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
prolog
/
sbprolog
/
sbp.zoo
/
sbp_v3.1
/
auxil
/
io.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-16
|
1KB
|
55 lines
/*$Source: /usr/home/dhesi/booz/RCS/io.c,v $*/
/*$Id: io.c,v 1.8 91/07/08 12:06:55 dhesi Exp $*/
/***********************************************************
Input/output for lzh decoding.
Adapted from "ar" archiver written by Haruhiko Okumura.
***********************************************************/
#include "booz.h"
#include "zoo.h"
#include "ar.h"
#include "lzh.h"
extern FILE *arcfile;
t_uint16 bitbuf;
static uint subbitbuf;
static int bitcount;
int fillbuf(int n)
{
bitbuf <<= n;
while (n > bitcount) {
bitbuf |= subbitbuf << (n -= bitcount);
if (feof(arcfile))
subbitbuf = 0;
else
subbitbuf = (uchar) getc(arcfile);
bitcount = CHAR_BIT;
}
bitbuf |= subbitbuf >> (bitcount -= n);
}
uint getbits(int n)
{
uint x;
x = bitbuf >> (BITBUFSIZ - n); fillbuf(n);
return x;
}
int fwrite_crc(uchar *p, int n, FILE *f)
{
if (f != NULL) {
if (fwrite((char *) p, 1, n, f) < n)
prterror('f', "disk full", (char *)0, (char *)0);
}
addbfcrc((char *) p, (unsigned) n);
}
int init_getbits(void)
{
bitbuf = 0; subbitbuf = 0; bitcount = 0;
fillbuf(BITBUFSIZ);
}